<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="edge" />
<link rel="shortcut icon" href="static/style/images/favicon.ico" />
<!-- [EasyUI] -->
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/gray/easyui.css" />
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/icon.css" />
<script type="text/javascript" src="/static/js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/static/js/HhUtil.js?t=20170109"></script>
<!-- [扩展样式] -->
<link rel="stylesheet" type="text/css" href="/static/css/dreamlu.css" />
<link rel="stylesheet" type="text/css" href="/static/css/icommon.css" />
<link rel="stylesheet" type="text/css" href="/static/css/login.css" />
<!--<script type="text/javascript" src="static/js/login.js" charset="utf-8"></script>-->
<title>用户管理</title>
<script type="text/javascript">
    var dataGrid;

    $(function () {
        //用户维护（新增、修改）界面
        $("#userDialog").dialog({
            title: "新增",
            width: ' 300px',
            height: '200px',
            closed: true,
            cache: false,
            modal: true,
            buttons: [{
                text: '保存',
                handler: function () {
                    saveUser();
                }
            }, {
                text: '关闭',
                handler: function () {

                    $("#userDialog").dialog("close");
                }
            }]
        });

        //首次进入拉取
        dataGrid = $('#dataGrid').datagrid({
            url: '/gettikulist',
            method:'get',
            fit: true,
            striped: true,
            rownumbers: true,
            pagination: true,
            singleSelect: true,
            queryParams: {
                vip: 'VIP1',
                exam_type: 1
            },
            idField: 'vip_id',
            sortName: 'vip_id',
            sortOrder: 'asc',
            pageSize: 30,
            pageList: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500],
            frozenColumns:[[
                {
                    width: '80',
                    title: ' id',
                    field: 'id',
                    hidden: true,
                },
                {
                    width: '80',
                    title: '题目ID',
                    field: 'sub_id',
                    sortable: true
                }, {
                    width: '80',
                    title: '车辆类型',
                    field: 'car_type'
                },{
                    width: '80',
                    title: '科目',
                    field: 'exam_type',
                    formatter: function (value, row, index) {
                        if (row.exam_type=='1'){
                            return '科目一'
                        }else{
                            return '科目四'
                        }

                    }
                },{
                    width: '80',
                    title: '章节',
                    field: 'sub_chapte'
                }
                ]],
            columns: [[{
                width: '80',
                title: 'VIP',
                field: 'vip',
            },{
                width: '80',
                title: 'VIP排序',
                field: 'vip_id',
            }, {
                width: '200',
                title: '题目',
                field: 'sub_title',
            }, {
                width: '80',
                title: '题目图片',
                field: 'sub_pic',
            },{
                width: '80',
                title: '题目属性',
                field: 'sub_class'
            },{
                width: '80',
                title: '题目类型',
                field: 'sub_type',
                formatter: function (value, row, index) {
                        if (row.exam_type=='1'){
                            return '判断'
                        }else{
                            return '选择'
                        }

                    }
            },{
                width: '80',
                title: '选项A',
                field: 'a',
            }, {
                width: '80',
                title: '选项B',
                field: 'b',
            }, {
                width: '80',
                title: '选项C',
                field: 'c',
            }, {
                width: '80',
                title: '选项D',
                field: 'd',
            }, {
                width: '80',
                title: '答案',
                field: 'answer'
            },
            {
                width: '160',
                title: '解析文字',
                field: 'sub_infos'
            }, {
                width: '80',
                title: '解析图片',
                field: 'info_pic'
            }, {
                width: '80',
                title: '答题技巧',
                field: 'dtjq'
            }, {
                width: '80',
                title: '技巧语音',
                field: 'jqyy'
            }, {
                width: '80',
                title: '更新时间',
                field: 'pubtime',
                sortable: true
            }]],

            toolbar: '#toolbar'
        });
            })



        //修改
        function update_vip_id(sub_id) {
			 var rows= dataGrid.datagrid('getSelected');

				if(rows == "undefined"||rows == null){
					HdUtil.messager.info("请选中编辑行");
					return;
				}
		        //= dataGrid.datagrid('getSelected');
                // id = rows.id;

            $("#userForm").form("clear").form("load", rows);
            $("#userDialog").dialog("open");
        }

        //保存
        function saveUser() {
            $("#userForm").form("submit", {
                url: "/updatevipid",
                onSumbit: function () {
                    $("#userForm").form.validate();
                },
                success: function (data) {
                    data = JSON.parse(data);
                    if (data.code == "0") {
                        $("#userDialog").dialog("close");
                        HdUtil.messager.slide(data.msg);
                        $("#dataGrid").datagrid("reload");
                    } else {
                        $("#userDialog").dialog("close");
                        HdUtil.messager.error(data.msg);
                    }
                }
            });
        }


        function searchFun() {
            dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
        }
        function cleanFun() {
            $('#searchForm input').val('');
            dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
        }

    </script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">

<div data-options="region:'center',border:true,title:'信息列表'">
  <table id="dataGrid" data-options="fit:true,border:false">
  </table>
</div>
<div id="toolbar" style="display: none;">
    <form id="searchForm">
        <table>
            <th>VIP分类:</th>
            <td><select id="vip" class="easyui-combobox" name="vip" style="width:150px;"
                        data-options="panelHeight:200">
                <option value="VIP1">VIP1</option>
                <option value="VIP2">VIP2</option>
                <option value="VIP3">VIP3</option>
                <option value="VIP4">VIP4</option>
                <option value="VIP5">VIP5</option>
                <option value="VIP6">VIP6</option>
                <option value="VIP7">VIP7</option>
            </select></td>
            <th>科目:</th>
            <td><select id="exam_type" class="easyui-combobox" name="exam_type" style="width:150px;"
                        data-options="panelHeight:200">
                <option value="1">科目一</option>
                <option value="4">科目四</option>

            </select></td>
            <td>
            <a href="javascript:void(0);" class="easyui-linkbutton"
               data-options="iconCls:'icon-search',plain:true" onclick="searchFun();">查询</a>
            <a href="javascript:void(0);" class="easyui-linkbutton"
                    data-options="iconCls:'icon-cancel',plain:true" onclick="cleanFun();">清空</a>
            <a onclick="update_vip_id();" href="javascript:void(0);" class="easyui-linkbutton"
               data-options="plain:true,iconCls:'icon-edit'">编辑</a>
        </td>


        </table>
    </form></div>
<div id="userDialog">
    <form id="userForm" method="post">
        <table>
            <br/>
            <tr>
                <td style="vertical-align: middle">VIP排序ID：</td>
                <td>
                    <input name="vip_id" class="easyui-textbox" data-options="required:true"/>
                    <input name="sub_id" style="display:none">
                    <input name="exam_type" style="display:none">
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>
